package mobi.hami.huapin.dao;

import java.util.Map;

public class NoteInfoProvider {

    public String selectNoteinfosWitchParam(Map<String,Object> parms){
        StringBuilder sb = new StringBuilder();
        sb.append("select * from note_info where ");
        if(null != parms && !parms.isEmpty()){
            if(null != parms.get("id") && !parms.get("id").equals("")){
                sb.append("id = ").append(parms.get("id")).append(" and ");
            }
            if(null != parms.get("comtent") && !parms.get("comtent").equals("")){
                sb.append("comtent like '%").append(String.valueOf(parms.get("comtent"))).append("%'").append(" and ");
            }
            if(null != parms.get("start_used_times") && !parms.get("start_used_times").equals("")){
                sb.append("used_times >= ").append(parms.get("start_used_times")).append(" and ");
            }
            if(null != parms.get("end_used_times") && !parms.get("end_used_times").equals("")){
                sb.append("used_times <= ").append(parms.get("end_used_times")).append(" and ");
            }
            if(null != parms.get("start_thumbup_times") && !parms.get("start_thumbup_times").equals("")){
                sb.append("thumbup_times >= ").append(parms.get("start_thumbup_times")).append(" and ");
            }
            if(null != parms.get("end_thumbup_times") && !parms.get("end_thumbup_times").equals("")){
                sb.append("thumbup_times <= ").append(parms.get("end_thumbup_times")).append(" and ");
            }
            if(null != parms.get("status") && !parms.get("status").equals("")){
                sb.append("status = ").append(parms.get("status")).append(" and ");
            }
            if(null != parms.get("start_create_time") && !parms.get("start_create_time").equals("")){
                sb.append("cretate_time >= '").append(parms.get("start_create_time").toString()).append("' and ");
            }
            if(null != parms.get("end_create_time") && !parms.get("end_create_time").equals("")){
                sb.append("cretate_time <= '").append(parms.get("end_create_time").toString()).append("' and ");
            }
        }
        sb.append("1 = 1 ");
        sb.append("order by cretate_time desc");
        return sb.toString();
    }

}
